#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "Data.h"

VOID
Coder(
	INT32* InputVector,
	INT32* Register,
	INT32* CodedVector,
	UINT32 BitNo
	)
{
	UINT32 ShiftCount 		 = 0;
	UINT32 idx 		 		 = 0;
	UINT32 CodedVectorOffset = 0;
	int MemoryRegister[REGISTER_CELL_NO] = {0};


	for(idx = 0, CodedVectorOffset = 0 ; idx < BitNo ; idx++, CodedVectorOffset+=2)
	{
		memcpy(MemoryRegister, Register, sizeof(MemoryRegister));
		/* Shift Register one position right */
		for(ShiftCount = 0 ; ShiftCount < REGISTER_CELL_NO - 1; ShiftCount++)
		{
			Register[ShiftCount + 1] = MemoryRegister[ShiftCount];
		}
		Register[0] = InputVector[idx];

		CodedVector[CodedVectorOffset + 1] = (Register[0] + Register[1] + Register[3] + Register[4] + Register[6]) % 2;
		CodedVector[CodedVectorOffset]     = (Register[0] + Register[3] + Register[4] + Register[5] + Register[6]) % 2;
	}
}
